module Ch02Test(tests) where

import Test.HUnit
import TestHelper
import Ch02

basicDropTests func =
    TestList["drop with remainder" ~: [3,4,5] @=? func 2 [1,2,3,4,5],
             "drop all" ~: [] @=? func 3 [1,2,3],
             "drop past end" ~: [] @=? func 4 [1,2],
             "drop none" ~: [1, 2] @=? func 0 [1,2],
             "drop negative" ~: [1, 2] @=? func (-7) [1,2]]

lazyRightDropTests func =
    TestList[basicDropTests func,
             "drop infinite" ~: [3,4,5] @=? take 3 (func 2 [1..])]

lazyLeftDropTests func =
    TestList[basicDropTests func,
             "drop undetermined count" ~: [] @=? func (length [1..]) []]

lastButOneTests func =
    TestList["basic" ~: 3 @=? func [1,2,3,4],
             "first" ~: 2 @=? func [2,3],
             "one element" @! func [1],
             "no elements" @! func []]

tests = TestList[lazyRightDropTests drop,
                 lazyRightDropTests myDrop, lazyRightDropTests myDrop2,
                 lazyLeftDropTests myDrop3,
                 lastButOneTests lastButOne, lastButOneTests lastButOne1]
